import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.text.NumberFormat;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.util.Timer;

final class VoluntaryThieve$Progress
{
  private final int skill = 17;
  private final int startingExp;
  private final long startingTime;
  private int pickpocketCount;
  private int pickpocketFailCount;
  private int glovesUsedCount;
  private int timesBankedCount;
  private int blackjackKnockCount;
  private int blackjackFailCount;
  private Rectangle experienceProgressBar;
  private boolean isHovering;
  private boolean isToggled;
  private final NumberFormat numberFormat = NumberFormat.getInstance();

  private VoluntaryThieve$Progress(VoluntaryThieve paramVoluntaryThieve)
  {
    this.startingExp = VoluntaryThieve.access$12800(paramVoluntaryThieve).getCurrentExp(17);
    this.startingTime = System.currentTimeMillis();
  }

  private void paint(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Composite localComposite = localGraphics2D.getComposite();
    localGraphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    int i = VoluntaryThieve.access$12900(this.this$0).getHeight() - 165 - 20;

    localGraphics2D.setPaint(Color.BLACK);
    localGraphics2D.setComposite(AlphaComposite.getInstance(3, 0.65F));
    localGraphics2D.fill(new Rectangle(4, i, VoluntaryThieve.access$13000(this.this$0).getWidth() - 253, 20));
    localGraphics2D.setComposite(localComposite);

    if (this.experienceProgressBar == null) {
      this.experienceProgressBar = new Rectangle(6, i + 2, 100, 15);
    }

    localGraphics2D.setColor(Color.WHITE);
    localGraphics2D.draw(this.experienceProgressBar);

    int j = VoluntaryThieve.access$13100(this.this$0).getPercentToNextLevel(17);
    if (j < 30) localGraphics2D.setColor(Color.RED); else {
      localGraphics2D.setColor(j < 70 ? Color.YELLOW : Color.GREEN);
    }

    int k = (int)Math.round(j / 100.0D * 100.0D);
    localGraphics2D.setComposite(AlphaComposite.getInstance(3, 0.5F));
    localGraphics2D.fillRect(7, i + 2 + 1, k, 14);

    localGraphics2D.setComposite(localComposite);

    int m = 0;

    long l = System.currentTimeMillis() - this.startingTime;
    int n = VoluntaryThieve.access$13200(this.this$0).getCurrentExp(17);
    int i1 = n - this.startingExp;
    double d = i1 * (1.0D / l);
    int i2;
    int i3;
    String str;
    if (this.isHovering)
    {
      int i4;
      if (this.isToggled)
      {
        i2 = (int)Math.round(this.pickpocketCount * (100.0D / (this.pickpocketCount + this.pickpocketFailCount)));

        i3 = (int)Math.round(this.pickpocketCount * (3600000.0D / l));
        i4 = (int)Math.round(this.blackjackKnockCount * (100.0D / (this.blackjackKnockCount + this.blackjackFailCount)));
        int i6;
        if (VoluntaryThieve.Options.access$900(VoluntaryThieve.access$800(this.this$0))) {
          i6 = (int)Math.round(this.blackjackKnockCount * (3600000.0D / l));

          str = new StringBuilder().append("SL: ").append(this.pickpocketCount).append(" (").append(i2).append(" %) | LH: ").append(i3).append(" | SK: ").append(this.blackjackKnockCount).append(" (").append(i4).append(" %) | FK: ").append(this.blackjackFailCount).append(" | KH: ").append(i6).toString();
        }
        else {
          i6 = (int)Math.round(this.glovesUsedCount * (3600000.0D / l));

          str = new StringBuilder().append("SP: ").append(this.pickpocketCount).append(" (").append(i2).append(" %) | FP: ").append(this.pickpocketFailCount).append(" | PH: ").append(i3).append(" | GU: ").append(this.glovesUsedCount).append(" | GH: ").append(i6).append(VoluntaryThieve.Options.access$2500(VoluntaryThieve.access$800(this.this$0)) ? new StringBuilder().append(" | TB: ").append(this.timesBankedCount).toString() : "").toString();
        }

        m = -1;
      }
      else
      {
        i2 = VoluntaryThieve.access$13300(this.this$0).getExpToNextLevel(17);
        i3 = n + i2;
        i4 = (int)Math.round(i2 / d);

        str = new StringBuilder().append("EP: ").append(n).append("/").append(i3).append(" (").append(j).append(" %) | ER: ").append(i2).append(" | TL: ").append(Timer.format(i4)).toString();

        m = -1;
      }
    }
    else
    {
      i2 = VoluntaryThieve.access$13400(this.this$0).getRealLevel(17);
      i3 = i2 - Skills.getLevelAt(this.startingExp);
      int i5 = (int)Math.round(d * 3600000.0D);

      str = new StringBuilder().append("TR: ").append(Timer.format(l)).append(" | CL: ").append(i2).append(" | LG: ").append(i3).append(" | EG: ").append(i1).append(" | EH: ").append(i5).toString();
    }

    localGraphics2D.setColor(Color.WHITE);
    localGraphics2D.setFont(new Font("Consolas", 0, 10));
    localGraphics2D.drawString(str, 113 + m, i + 2 + 10 + 1);
  }

  private void print()
  {
    if (!VoluntaryThieve.Actions.Methods.access$13600(VoluntaryThieve.Actions.access$1700(VoluntaryThieve.access$13500(this.this$0)))) return;

    long l = System.currentTimeMillis() - this.startingTime;
    int i = VoluntaryThieve.access$13700(this.this$0).getCurrentExp(17) - this.startingExp;
    int j = VoluntaryThieve.access$13800(this.this$0).getRealLevel(17) - Skills.getLevelAt(this.startingExp);

    String str = new StringBuilder().append("Gained ").append(this.numberFormat.format(i)).append(" exp (").append(j).append(" ").append(j == 1 ? "level" : "levels").append(") in ").append(Timer.format(l)).append(", performing ").append(this.numberFormat.format(this.pickpocketCount)).append(" ").toString();

    if (VoluntaryThieve.Options.access$900(VoluntaryThieve.access$800(this.this$0))) str = new StringBuilder().append(str).append(this.pickpocketCount == 1 ? "loot" : "loots").toString(); else
      str = new StringBuilder().append(str).append(this.pickpocketCount == 1 ? "pickpocket" : "pickpockets").toString();
    this.this$0.log(new StringBuilder().append(str).append(".").toString());
  }

  private void processMousePressed(MouseEvent paramMouseEvent)
  {
    if (this.isHovering) this.isToggled = (!this.isToggled);
  }

  private void processMouseMoved(MouseEvent paramMouseEvent)
  {
    this.isHovering = ((this.experienceProgressBar != null) && (this.experienceProgressBar.contains(paramMouseEvent.getPoint())));

    if (!this.isHovering) this.isToggled = false;
  }
}